package SpanishExercise;
import java.util.Scanner;
import java.util.Random;
import java.io.*;
class SpanishNumber{
	final static String[] below30={"cero","uno","dos","tres","cuatro",
			"cinco","seis","siete","ocho","nueve","diez","once","doce",
			"trece","catorce","quince","dieciséis","diecisiete",
			"dieciocho","diecinueve","veinte","veintiuno","veintidós",
			"veintitrés","veinticuatro","veinticinco","veintiséis",
			"veintisiete","veintiocho","veintinueve"};
	final static String[] tenth={"treinta","cuarenta","cincuenta","sesenta","setenta",
			"ochenta","noventa","cien"};
	final static String[] hundredth={"ciento","doscientos","trecientos", "cuatrocientos",
			"quinientos", "seiscientos","setecientos","ochocientos","novecientos"};
	private static String toBelow30(int value){
		value %= 30;
		return below30[value];
	}
	private static String toBelow101(int value){
		value %= 100;
		if(value < 30) return toBelow30(value);
		int tenValue=value /10;
		value %= 10;
		return tenth[tenValue-3] + ((value==0) ? "" : " y "+ toBelow30(value));
	}
	private static String toBelow1000(int value){
		value %= 1000;
		if(value<101) return toBelow101(value);
		int hundredValue=value / 100;
		value %= 100;
		return hundredth[hundredValue - 1] 
			+ ((value==0) ? "" : " " + toBelow101(value));
	}
	private static String toBelow1000000(int value){
		value %= 1000000;
		if(value<1000) return toBelow1000(value);
		if(value==1000) return "mil";
		int thousandValue= value / 1000;
		if(value<2000) return "mil " + toBelow1000(value);
		value %= 1000;
		return toBelow1000(thousandValue) + " mil" + ((value==0)?"":" "+toBelow1000(value));
	}
	public static String toString(int value){
		return toBelow1000000(value);
	}
}
